document.getElementById('submit-div').addEventListener('click', function(event) {
    event.preventDefault(); // 阻止表单默认提交行为

    // 获取用户输入的值
    const url = document.getElementById('form-url').value;
    const key = document.getElementById('form-key').value;
    const model = document.getElementById('form-model').value;

    localStorage.setItem("url", url)
    localStorage.setItem("key", key)
    localStorage.setItem("model", model)
    // alert('数据已保存！');
    if(url && key && model) {
        location.href = 'popup.html'
    }

});


document.addEventListener('DOMContentLoaded', function() {
    document.getElementById('form-url').value = localStorage.getItem("url") ?? 'https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions'
    document.getElementById('form-model').value = localStorage.getItem("model") ?? 'deepseek-r1,deepseek-v3,qwen-max-latest'
    document.getElementById('form-key').value = localStorage.getItem("key")
    console.log("hello world")
});